<?php
/**
 * wp-foundation theme-options.php
 */
?>
<?php
$themename = "foundation";
$shortname = "fd";
$options = array (

//////// TABS NAVIGATION ////////////
array("type" => "tabs-wrap-start"),

///////////////// BEGIN TAB AREA 1 /////////////////////////////////
array("type" => "tabs-minor-wrap-start", "name" => "tabs-1"),
array("type" => "tabs-minor-heading", "name" => "Navigation Options", "image" => "pages"),
array("type" => "tabs-minor-start"),

//begin panel 1
array("type" => "tabs-minor-panel-start", "name" => "nav1"),

array(    
	"name" => "Top Navigation Placement",
	"id" => $shortname."_nav_placement",
	"type" => "select",
	"std" => "Inside Header",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"options" => array("Inside Header", "Above Header", "Below Header", "Remove")),

array(    
	"name" => "Enable/Disable Home Link",
	"id" => $shortname."_home_link",
	"type" => "select",
	"std" => "Enable",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"options" => array("Enable", "Disable")),

array(
	"name" => "Include Pages In Top Nav",
	"id" => $shortname."_include_page",
	"std" => "",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "textincpage"),

array(
	"name" => "Exclude Pages In Top Nav",
	"id" => $shortname."_exclude_page",
	"std" => "",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "textexpage"),

array("type" => "tabs-minor-panel-end"),
//end panel 1

array("type" => "tabs-minor-end"),
array("type" => "tabs-minor-wrap-end"),
///////////////// END TAB AREA 1 /////////////////////////////////


///////////////// BEGIN TAB AREA 2 /////////////////////////////////
array("type" => "tabs-minor-wrap-start", "name" => "tabs-2"),
array("type" => "tabs-minor-heading", "name" => "Banner Options", "image" => "media"),
array("type" => "tabs-minor-start"),

array("type" => "tabs-side-start"),
array("type" => "tabs-side", "name" => "ban1", "option" => "Banner Effects"),
array("type" => "tabs-side", "name" => "ban2", "option" => "Banner Image 1"),
array("type" => "tabs-side", "name" => "ban3", "option" => "Banner Image 2"),
array("type" => "tabs-side", "name" => "ban4", "option" => "Banner Image 3"),
array("type" => "tabs-side-end"),

//begin panel 1
array("type" => "tabs-minor-panel-start", "name" => "ban1"),

array(    
	"name" => "Enable/Disable Home Banner",
	"id" => $shortname."_enable_home_banner",
	"type" => "select",
	"std" => "Enable",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"options" => array("Enable", "Disable")),

array(    
	"name" => "Home Banner Location",
	"id" => $shortname."_home_banner_location",
	"type" => "select",
	"std" => "Below Header",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"options" => array("Below Header", "Above Header")),

array(    
	"name" => "Choose Banner Effect",
	"id" => $shortname."_home_banner_effect",
	"type" => "select",
	"std" => "fade",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"options" => array("blindX", "blindY", "blindZ", "cover", "curtainX", "curtainY", "fade", "fadeZoom", "growX", "growY", "scrollUp", "scrollDown", "scrollLeft", "scrollRight", "scrollHorz", "scrollVert", "shuffle", "slideX", "slideY", "toss", "turnUp", "turnDown", "turnLeft", "turnRight", "uncover", "wipe", "zoom")),

array("type" => "tabs-minor-panel-end"),
//end panel 1

//begin panel 2
array("type" => "tabs-minor-panel-start", "name" => "ban2"),

array(
	"name" => "Image 1 Url",
	"id" => $shortname."_image1_url",
	"std" => get_bloginfo( 'template_directory' ) . "/images/splash/splash1.jpg",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array(
	"name" => "Image 1 Alt Tag",
	"id" => $shortname."_image1_alt",
	"std" => "Image 1",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array(
	"name" => "Image 1 Title Tag",
	"id" => $shortname."_image1_title",
	"std" => "Image 1 Title",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array(
	"name" => "Image 1 Width",
	"id" => $shortname."_image1_width",
	"std" => "960",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array(
	"name" => "Image 1 Height",
	"id" => $shortname."_image1_height",
	"std" => "350",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array("type" => "tabs-minor-panel-end"),
//end panel 2

//begin panel 3
array("type" => "tabs-minor-panel-start", "name" => "ban3"),

array(    
	"name" => "Enable/Disable Image 2",
	"id" => $shortname."_image2_active",
	"std" => "Enable",
	"type" => "select",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"options" => array("Enable", "Disable")),

array(
	"name" => "Image 2 Url",
	"id" => $shortname."_image2_url",
	"std" => get_bloginfo( 'template_directory' ) . "/images/splash/splash2.jpg",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array(
	"name" => "Image 2 Alt Tag",
	"id" => $shortname."_image2_alt",
	"std" => "Image 2",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array(
	"name" => "Image 2 Title Tag",
	"id" => $shortname."_image2_title",
	"std" => "Image 2 Title",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array(
	"name" => "Image 2 Width",
	"id" => $shortname."_image2_width",
	"std" => "960",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array(
	"name" => "Image 2 Height",
	"id" => $shortname."_image2_height",
	"std" => "350",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array("type" => "tabs-minor-panel-end"),
//end panel 3

//begin panel 4
array("type" => "tabs-minor-panel-start", "name" => "ban4"),

array(    
	"name" => "Enable/Disable Image 3",
	"id" => $shortname."_image3_active",
	"std" => "Disable",
	"type" => "select",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"options" => array("Disable", "Enable")),

array(
	"name" => "Image 3 Url",
	"id" => $shortname."_image3_url",
	"std" => get_bloginfo( 'template_directory' ) . "/images/splash/splash3.jpg",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array(
	"name" => "Image 3 Alt Tag",
	"id" => $shortname."_image3_alt",
	"std" => "Image 3",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array(
	"name" => "Image 3 Title Tag",
	"id" => $shortname."_image3_title",
	"std" => "Image 3 Title",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array(
	"name" => "Image 3 Width",
	"id" => $shortname."_image3_width",
	"std" => "960",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array(
	"name" => "Image 3 Height",
	"id" => $shortname."_image3_height",
	"std" => "350",
	"desc" => "More info at our site.",
	"link" => "http://www.wp-foundation.com/",
	"type" => "text"),

array("type" => "tabs-minor-panel-end"),
//end panel 4

array("type" => "tabs-minor-end"),
array("type" => "tabs-minor-wrap-end"),
///////////////// END TAB AREA 2 /////////////////////////////////


array("type" => "tabs-wrap-end"),
);
/////////////////////////////////////////////

/*Add a Theme Options Page*/
function mytheme_add_admin() {
    global $themename, $shortname, $options;
    if ( $_GET['page'] == basename(__FILE__) ) {
        if ( 'save' == $_REQUEST['action'] ) {
                foreach ($options as $value) {
                    update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
                foreach ($options as $value) {
                    if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
                header("Location: themes.php?page=theme-options.php&saved=true");
                die;
        } else if( 'reset' == $_REQUEST['action'] ) {
            foreach ($options as $value) {
                delete_option( $value['id'] ); }
            header("Location: themes.php?page=theme-options.php&reset=true");
            die;
        }}
    add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}

function mytheme_admin() {
    global $themename, $shortname, $options;
	if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' '.__('settings saved.','foundation').'</strong></p></div>';
    if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' '.__('settings reset.','foundation').'</strong></p></div>';
?>


<div class="fd-options-wrap">

<form method="post">

<?php foreach ($options as $value) {
switch ( $value['type'] ) {

case "selections-wrap-start": ?>
<div id="<?php echo $value['cssid']; ?>" class="fd-selections-wrap">
<?php break;

case "selections-wrap-end": ?>
</div>
<?php break;

case "misc": ?>
<div class="fd-misc">
	<?php echo $value['name']; ?>
</div>
<?php break;

case "title": ?>
<div id="<?php echo $value['cssid']; ?>" class="fd-selections-title">
<div class="<?php echo $value['imageStyle']; ?> fd-title-icon">&nbsp;</div>
	<?php echo $value['name']; ?>
<div class="icon-open fd-title-toggle">&nbsp;</div>
</div>
<?php break;

case 'text': ?>
<div class="fd-option-wrap">
	<div class="fd-option-heading"><span><?php echo $value['name']; ?></span>
    	<span class="fd-option-desc ui-state-default fd-option-icon">
        	<a href="<?php echo $value['link']; ?>" target="_blank" class="ui-icon ui-icon-info" title="<?php echo $value['desc']; ?>">&nbsp;</a>
        </span>
    </div>
	<input class="fd-option-input" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'] )); } else { echo stripslashes($value['std']); } ?>" />
</div>
<?php
break;

case 'textarea': ?>
<div class="fd-option-wrap">
	<div class="fd-option-heading"><?php echo $value['name']; ?></div>
	<textarea name="<?php echo $value['id']; ?>" class="fd-option-textbox" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'] )); } else { echo stripslashes($value['std']); } ?></textarea>
	<div class="fd-option-desc"><?php echo $value['desc']; ?></div>
</div>
<?php
break;

case 'select': ?>
<div class="fd-option-wrap">
	<div class="fd-option-heading"><span><?php echo $value['name']; ?></span>
    	<span class="fd-option-desc ui-state-default fd-option-icon">
        	<a href="<?php echo $value['link']; ?>" target="_blank" class="ui-icon ui-icon-info" title="<?php echo $value['desc']; ?>">&nbsp;</a>
        </span>
    </div>
    <div class="fd-option-select-wrap">
	<select class="fd-option-select" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select>
    </div>
</div>
<?php
break;

case "checkbox": ?>
<div class="fd-option-wrap">
	<div class="fd-option-heading"><?php echo $value['name']; ?></div>
		<?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
        <input class="fd-option-checkbox" type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
        <div class="fd-option-desc"><?php echo $value['desc']; ?></div>
</div>
<?php
break;

case 'textincpage': ?>
<div class="fd-option-wrap">
	<div class="fd-option-heading"><span><?php echo $value['name']; ?></span>
    	<span class="fd-option-desc ui-state-default fd-option-icon">
        	<a href="<?php echo $value['link']; ?>" target="_blank" class="ui-icon ui-icon-info" title="<?php echo $value['desc']; ?>">&nbsp;</a>
        </span>
    </div>
	<input class="fd-option-input" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="text" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'] )); } else { echo stripslashes($value['std']); } ?>" />
	<?php
	 wp_dropdown_pages(array('exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'fd-select-include-pages', 'show_option_none' => __('Select pages to include'), 'sort_column'=> 'menu_order, post_title'));
	?>
</div>
<?php
break;


case 'textexpage': ?>
<div class="fd-option-wrap">
	<div class="fd-option-heading"><span><?php echo $value['name']; ?></span>
    	<span class="fd-option-desc ui-state-default fd-option-icon">
        	<a href="<?php echo $value['link']; ?>" target="_blank" class="ui-icon ui-icon-info" title="<?php echo $value['desc']; ?>">&nbsp;</a>
        </span>
    </div>
	<input class="fd-option-input" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="text" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'] )); } else { echo stripslashes($value['std']); } ?>" />
	<?php
	 wp_dropdown_pages(array('exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'fd-select-exclude-pages', 'show_option_none' => __('Select pages to exclude'), 'sort_column'=> 'menu_order, post_title'));
	?>
</div>
<?php
break;

case 'textimgop': ?>
<div class="fd-option-wrap">
	<div class="fd-option-heading"><?php echo $value['name']; ?></div>

<?php
break;

case "textimgop-wrap-end": ?>
</div>
<?php break; ?>

<?php case "tabs-wrap-start": ?>
<div id="tabs">
    <ul class="top-tabs-nav">
        <li><a href="#tabs-1">Top Navigation</a></li>
        <li><a href="#tabs-2">Home Banner</a></li>
    </ul>
<?php break; ?>

<?php case "tabs-minor-wrap-start": ?>    
    <div id="<?php echo $value['name']; ?>" class="tabs-minor-wrap">
<?php break; ?>

<?php case "tabs-minor-heading": ?> 
        <div class="tabs-minor-heading"><span class="heading-<?php echo $value['image']; ?>">&nbsp;</span><?php echo $value['name']; ?></div>
<?php break; ?>

<?php case "tabs-minor-start": ?> 
        <div class="tabs-minor">
<?php break; ?>

<?php case "tabs-side-start": ?> 
            <ul class="tabs-side">
<?php break; ?>

<?php case "tabs-side": ?>
                <li><a href="#tabs-side-<?php echo $value['name']; ?>"><?php echo $value['option']; ?></a></li>
<?php break; ?>
                
<?php case "tabs-side-end": ?>
            </ul>
<?php break; ?>

<?php case "tabs-minor-panel-start": ?>
            <div class="tabs-minor-panel" id="tabs-side-<?php echo $value['name']; ?>">
<?php break; ?>

<?php case "tabs-minor-panel-end": ?>
            </div>
<?php break; ?>
            
<?php case "tabs-minor-end": ?>
        </div>
<?php break; ?>
        
<?php case "tabs-minor-wrap-end": ?>  
    </div><!-- .eof #tabs-minor-wrap -->
<?php break; ?>

<?php case "tabs-wrap-end": ?>
</div><!-- .eof #tabs -->
<?php break; ?>

<?php 	}// .eof switch 
		}// .eof foreach
		?>
 
    <p class="submit"  id="fd-save">
        <input name="save" type="submit" value="Save changes" />
        <input type="hidden" name="action" value="save" />
    </p>
</form>

<form method="post">
    <p class="submit"  id="fd-reset">
        <input name="reset" type="submit" value="Reset" />
        <input type="hidden" name="action" value="reset" />
    </p>
</form>

<?php
}

add_action('admin_menu', 'mytheme_add_admin');
/*End of Add a Theme Options Page*/

/*End of Theme Options =======================================*/
?>